home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / msdos / mcpr / mcpprt.asm < prev    next >
Assembly Source File  |  1991-10-18  |  10KB  |  674 lines

  1.     page    95,132
  2. ;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
  3. ;§                                                                          §
  4. ;§            マルチカラム コンパクト プリント ユーティリティ            §
  5. ;§                                                                          §
  6. ;§   Multicolumn Compact PRint utility   MCPR.EXE  Ver1.40    §
  7. ;§   ~           ~       ~~                                                 §
  8. ;§              Copyright (C) by 福地 邦雄 1989-1990. All rights reserved.  §
  9. ;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
  10.     public    codeprint
  11.     public    bitprint
  12.     public    prtinit
  13.     public    feedprint
  14.     public    dosprint
  15.     extrn    inttoascs:near
  16.     extrn    abort:near
  17.     extrn    intflg:byte
  18.     extrn    reprintflg:word
  19. ;
  20. YES    equ    1
  21. PORT    equ    0
  22. LAND    equ    1
  23. STOCK136 equ    0
  24. STOCK80 equ    1
  25. A4    equ    2
  26. B4    equ    3
  27. ;
  28. data    segment para    public    'DATA'
  29. ;
  30. extrn    bitimgseg:word
  31. extrn    prtbufseg:word
  32. extrn    marginhead:word
  33. extrn    hdrprint:word
  34. extrn    creturns:word
  35. extrn    linptr:dword
  36. extrn    clmpitch:word
  37. extrn    rawpitch:word
  38. extrn    pprtype:word
  39. extrn    frmtype:word
  40. extrn    hopper:word
  41. extrn    lincnt:word
  42. extrn    filline:word
  43. extrn    errorno:word
  44. ;
  45. pgprtinit    dw    ?
  46. initsiz        dw    ?
  47. ;
  48. clm1data    db  1ch,'(`',71h,1bh,'$B',1ch,'$',23h,76h,1bh,'(H'
  49. clm1dsiz    equ        $-clm1data
  50. raw2data    db    1ch,'%',22h,74h
  51. raw2dsiz    equ     $-raw2data
  52. r2c1dsiz    equ     $-clm1data
  53. raw3data    db    1ch,'%',22h,70h,1bh,'[10e'
  54. raw3dsiz    equ     $-raw3data
  55. clm2data    db    1bh,'$B',1ch,'$',22h,74h,1bh,'(H',1bh,'Q1 |',1bh,'[;12 G'
  56. clm2dsiz    equ     $-clm2data
  57. r2c2data    db    1bh,'$B',1ch,'$',22h,74h,1bh,'(H',1bh,'Q1 |',1bh,'[24;12 G'
  58. r2c2dsiz    equ     $-r2c2data
  59. ;
  60. hmargin     dw        ?
  61. crcount     dw        ?
  62. feedata     db        1bh,'E'
  63. clrbuff        db        18h
  64. ;
  65. leddirsq    db    1bh,'Q'
  66. ledcood     db    '0;4;'
  67. ledhopper   db    '0;'
  68. leddir      db    '0!@'
  69. ledirsqsz   equ     $-leddirsq
  70. ;
  71. ledinitstr  db    48 dup(?)
  72. ;
  73. srlcsfsq    db    1bh,'Q10 [',1bh,'Q2'
  74. srlhopper   db    '0 [',1bh,'Q0 ['
  75. srlcsfsqsz  equ    $-srlcsfsq
  76. ;
  77. printmsg    db    'print error',0dh,0ah
  78. prtmsgsiz   equ     $-printmsg
  79. ;
  80. rdfontj    db    32 dup(0)
  81. chcnt    db    16
  82. bytcnt    db    2
  83. side    dw    0
  84. prtfont    db    32 dup(0)
  85. ;
  86. makeankbit    dw    ankimgcnvt
  87. ankscale    dw    0810h
  88. ;
  89. data    ends
  90. ;
  91. code    segment para    public    'CODE'
  92.     assume    cs:code,ds:data
  93. ;
  94. lcount        equ     word ptr [bp+00h]
  95. ;
  96. aryptr        equ     [bp+02h]
  97. aryoff        equ     word ptr [bp+02h]
  98. saveds        equ     [bp+04h]
  99. ;
  100. chrptr        equ     [bp+06h]
  101. chroff        equ     word ptr [bp+06h]
  102. chrseg        equ     [bp+08h]
  103. ;
  104. prtptr        equ     [bp+0ah]
  105. prtoff        equ     word ptr [bp+0ah]
  106. prtseg        equ     [bp+0ch]
  107. ;
  108. bitptr        equ     [bp+0eh]
  109. bitoff        equ     word ptr [bp+0eh]
  110. bitseg        equ     [bp+10h]
  111. ;
  112. savelines   equ     [bp+12h]
  113. ;
  114. codeprint   proc
  115. ;
  116.     push    si
  117.     push    ax
  118.     push    ax
  119.     mov    bp,sp
  120. cdreprint:
  121.     mov    dx,offset clrbuff
  122.     mov    cx,1
  123.     call    dosprint
  124.     jnz    cdreprint
  125.     mov    dx,pgprtinit
  126.     mov    cx,initsiz
  127.     call    dosprint
  128.     jnz    cdreprint
  129.     call    headmargin
  130.     mov    ax,ds
  131.     mov    es,ax
  132.     mov    di,offset linptr
  133.     cmp    hdrprint,YES
  134.     jne    cdlinloop
  135.     add    lcount,2
  136.     lea    di,[di-8]
  137. cdlinloop:
  138.     lds    si,es:[di]
  139.     mov    word ptr [si],451bh
  140.     lea    cx,[si+2]
  141.     xor    dx,dx
  142.     call    dosprint
  143.     jnz    codehead
  144. ;
  145.     lea    di,[di+4]
  146.     dec    lcount
  147.     jnz    cdlinloop
  148. ;
  149.     mov    ax,es
  150.     mov    ds,ax
  151.     pop    ax
  152.     pop    si
  153.     pop    si
  154.     ret
  155. ;
  156. codehead:
  157.     mov    ax,es
  158.     mov    ds,ax
  159.     mov    ax,[bp+2]
  160.     mov    [bp],ax
  161.     jmp    cdreprint
  162. ;
  163. codeprint   endp
  164. ;
  165. bitprint    proc
  166. ;
  167.     push    si
  168.     push    ds
  169.     sub    sp,14h
  170.     mov    bp,sp
  171. bitreprint:
  172.     call    bitwrkinit
  173. bitreprint2:
  174.     mov    dx,offset clrbuff
  175.     mov    cx,1
  176.     call    dosprint
  177.     jnz    bitreprint2
  178.     mov    dx,pgprtinit
  179.     mov    cx,initsiz
  180.     call    dosprint
  181.     jnz    bitreprint2
  182.     call    headmargin
  183.     jnz    bitreprint2
  184. lineloop:
  185.     mov    bitoff,0
  186.     mov    prtoff,0
  187.     mov    chroff,0
  188.     les    di,aryptr
  189.     mov    ax,es:[di+2]
  190.     mov    chrseg,ax
  191. charloop:
  192.     les    di,chrptr
  193.     xor    ax,ax
  194.     mov    al,es:[di]
  195.     inc    di
  196.     mov    chroff,di
  197.     test    al,al
  198.     jz    endline
  199.     jns    spctest
  200.     cmp    al,0a0h
  201.     jb    knjset
  202.     cmp    al,0e0h
  203.     jae    knjset
  204. spctest:
  205.     cmp    al,' '
  206.     jne    ankset
  207.     cmp    byte ptr es:[di],' '
  208.     jne    ankset
  209.     call    skipspace
  210.     jmp    short charloop
  211. ankset:
  212.     call    ankimgset
  213.     jmp    short charloop
  214. knjset:
  215.     call    knjimgset
  216.     jmp    short charloop
  217. endline:
  218.     call    copyimgdata
  219.     mov    word ptr es:[di],451bh
  220.     lea    di,[di+2]
  221. ;
  222.     mov    cx,di
  223.     xor    dx,dx
  224.     mov    ds,prtseg
  225.     call    dosprint
  226.     jnz    bithead
  227. ;
  228.     add    aryoff,4
  229.     dec    lcount
  230.     jz    endprint
  231.     jmp    lineloop
  232. endprint:
  233.     add    sp,14h
  234.     pop    ds
  235.     pop    si
  236.     ret
  237. ;
  238. bithead:
  239.     mov    ds,saveds
  240.     mov    ax,savelines
  241.     jmp    bitreprint
  242. ;
  243. bitprint    endp
  244. ;
  245. bitwrkinit  proc
  246. ;
  247.     mov    lcount,ax
  248.     mov    savelines,ax
  249.     mov    ax,offset linptr
  250.     cmp    hdrprint,YES
  251.     jne    nohdrprt
  252.     add    lcount,2
  253.     sub    ax,8
  254. nohdrprt:
  255.     mov    aryoff,ax
  256.     mov    saveds,ds
  257.     mov    ax,bitimgseg
  258.     mov    bitseg,ax
  259.     mov    ax,prtbufseg
  260.     mov    prtseg,ax
  261.     ret
  262. ;
  263. bitwrkinit  endp
  264. ;
  265. skipspace   proc
  266. ;
  267.     mov    cx,-1
  268.   repe    scasb
  269.     dec    di
  270.     mov    chroff,di
  271.     not    cx
  272.     mov    ax,9
  273.     mul    cx
  274.     push    ax
  275.     call    copyimgdata
  276.     pop    ax
  277.     mov    word ptr es:[di],5b1bh
  278.     lea    di,[di+2]
  279.     call    inttoascs
  280.     mov    byte ptr es:[di],'a'
  281.     inc    di
  282.     mov    prtoff,di
  283.     ret
  284. ;
  285. skipspace   endp
  286. ;
  287. ankimgset   proc
  288. ;
  289.     push    ds
  290.     xor    bx,bx
  291.     mov    bl,al
  292.     mov    ax,data
  293.     mov    ds,ax
  294. ;
  295.     mov    ax,700h
  296.     mov    dx,ankscale
  297.     mov    di,offset rdfontj
  298.     int    91h
  299. ;
  300.     call    makeankbit
  301.     xor    ax,ax
  302.     mov    cx,8
  303.     mov    si,offset prtfont
  304.     les    di,bitptr
  305. ankimgloop:
  306.     movsw
  307.     stosb
  308.     loop    ankimgloop
  309.     stosw
  310.     stosb
  311.     mov    bitoff,di
  312.     pop    ds
  313.     ret
  314. ;
  315. ankimgset   endp
  316. ;
  317. ankimgcnvt    proc
  318. ;
  319.     mov    di,offset prtfont
  320.     mov    chcnt,8
  321.     mov    bl,80h
  322. aclabel4:
  323.     mov    si,offset rdfontj
  324.     mov    bytcnt,2
  325. aclabel5:
  326.     mov    cx,8
  327.     xor    ax,ax
  328. aclabel6:
  329.     mov    al,[si]            ;get font data
  330.     and    al,bl
  331.     jz    acbitnoset
  332.     stc
  333. acbitnoset:
  334.     rcl    ah,1
  335.     inc    si
  336.     loop    aclabel6
  337. ;
  338.     mov    [di],ah
  339.     inc    di
  340.     dec    bytcnt
  341.     jnz    aclabel5
  342. ;
  343.     shr    bl,1
  344.     dec    chcnt
  345.     jnz    aclabel4
  346. ;
  347.     ret
  348. ;
  349. ankimgcnvt    endp
  350. ;
  351. betaimgcnvt    proc
  352. ;
  353.     mov    di,offset prtfont
  354.     mov    chcnt,8
  355.     mov    bl,80h
  356. bclabel4:
  357.     mov    si,offset rdfontj
  358.     mov    bytcnt,2
  359. bclabel5:
  360.     mov    cx,4
  361.     xor    ax,ax
  362. bclabel6:
  363.     shl    ah,1
  364.     shl    ah,1
  365.     mov    al,[si]            ;get font data
  366.     and    al,bl
  367.     jz    bcbitnoset
  368.     or    ah,3
  369. bcbitnoset:
  370.     inc    si
  371.     loop    bclabel6
  372. ;
  373.     mov    [di],ah
  374.     inc    di
  375.     dec    bytcnt
  376.     jnz    bclabel5
  377. ;
  378.     shr    bl,1
  379.     dec    chcnt
  380.     jnz    bclabel4
  381. ;
  382.     ret
  383. ;
  384. betaimgcnvt    endp
  385. ;
  386. knjimgset   proc
  387. ;
  388.     push    ds
  389.     xor    bx,bx
  390.     mov    bl,es:[di]
  391.     inc    di
  392.     mov    chroff,di
  393. ;
  394.     cmp    al,0e0h
  395.     jb    sjblock1
  396.     sub    al,40h
  397. sjblock1:
  398.     sub    al,81h
  399.     shl    al,1
  400.     add    al,21h
  401. ;
  402.     test    bl,bl
  403.     jns    nohighbit
  404.     dec    bl
  405. nohighbit:
  406.     cmp    bl,9eh
  407.     jb    lowside
  408.     inc    al
  409.     sub    bx,5eh
  410. lowside:
  411.     sub    bx,1fh
  412. ;
  413.     mov    bh,al
  414.     xchg    bh,bl
  415.     mov    ax,data
  416.     mov    ds,ax
  417. ;
  418.     mov    ax,700h
  419.     mov    dx,1010h
  420.     mov    di,offset rdfontj
  421.     int    91h
  422. ;
  423.     call    knjimgcnvt
  424.     xor    ax,ax
  425.     mov    cx,16
  426.     mov    si,offset prtfont
  427.     les    di,bitptr
  428. ;
  429.     stosw
  430.     stosb
  431. knjimgloop:
  432.     movsw
  433.     stosb
  434.     loop    knjimgloop
  435.     stosw
  436.     stosb
  437.     mov    bitoff,di
  438.     pop    ds
  439.     ret
  440. ;
  441. knjimgset   endp
  442. ;
  443. knjimgcnvt    proc
  444. ;
  445.     mov    di,offset prtfont
  446. jclabel3:
  447.     mov    chcnt,8
  448.     mov    bl,80h
  449. jclabel4:
  450.     mov    si,offset rdfontj
  451.     add    si,side
  452.     mov    bytcnt,2
  453. jclabel5:
  454.     mov    cx,8
  455.     xor    ax,ax
  456. jclabel6:
  457.     mov    al,[si]            ;get font data
  458.     and    al,bl
  459.     jz    jcbitnoset
  460.     stc
  461. jcbitnoset:
  462.     rcl    ah,1
  463.     lea    si,[si+2]
  464.     loop    jclabel6
  465. ;
  466.     mov    [di],ah
  467.     inc    di
  468.     dec    bytcnt
  469.     jnz    jclabel5
  470. ;
  471.     shr    bl,1
  472.     dec    chcnt
  473.     jnz    jclabel4
  474. ;
  475.     xor    side,1
  476.     jnz    jclabel3
  477. ;
  478.     ret
  479. ;
  480. knjimgcnvt    endp
  481. ;
  482. copyimgdata proc
  483. ;
  484.     les    di,prtptr
  485.     mov    ax,bitoff
  486.     test    ax,ax
  487.     jz    noimgdata
  488.     mov    word ptr es:[di],511bh
  489.     lea    di,[di+2]
  490.     cwd
  491.     mov    bx,3
  492.     div    bx
  493.     call    inttoascs
  494.     mov    word ptr es:[di],'W '
  495.     lea    di,[di+2]
  496.     xor    ax,ax
  497.     mov    si,ax
  498.     mov    cx,bitoff
  499.     shr    cx,1
  500.     mov    ds,bitseg
  501.     rep movsw
  502.     test    bitoff,1
  503.     jz    evenoff
  504.     movsb
  505. evenoff:
  506.     mov    bitoff,ax
  507.     mov    prtoff,di
  508. noimgdata:
  509.     ret
  510. ;
  511. copyimgdata endp
  512. ;
  513. prtinit     proc
  514. ;
  515.     cmp    clmpitch,2
  516.     je    pgw2
  517.     ja    pgw3
  518. ;
  519.     cmp    rawpitch,2
  520.     jne    nochange
  521.     mov    pgprtinit,offset clm1data
  522.     mov    initsiz,r2c1dsiz
  523.     jmp    short pitchend
  524. pgw2:
  525.     cmp    rawpitch,1
  526.     jne    w2pgh2
  527.     mov    pgprtinit,offset clm2data
  528.     mov    initsiz,clm2dsiz
  529.     jmp    short pitchend
  530. w2pgh2:
  531.     mov    pgprtinit,offset r2c2data
  532.     mov    initsiz,r2c2dsiz
  533.     jmp    short pitchend
  534. pgw3:
  535.     cmp    rawpitch,2
  536.     jb    nochange
  537.     ja    w3pgh3
  538.     mov    pgprtinit,offset raw2data
  539.     mov    initsiz,raw2dsiz
  540.     jmp    short pitchend
  541. w3pgh3:
  542.     mov    pgprtinit,offset raw3data
  543.     mov    initsiz,raw3dsiz
  544.     cmp    creturns,YES
  545.     jne    pitchend
  546.     sub    initsiz,5
  547.     jmp    short pitchend
  548. nochange:
  549.     mov    pgprtinit,offset clm1data
  550.     mov    initsiz,clm1dsiz
  551. pitchend:
  552.     cmp    pprtype,STOCK80
  553.     jbe    serialprt
  554.     cld
  555.     mov    cx,ds
  556.     mov    es,cx
  557.     mov    cx,initsiz
  558.     mov    si,pgprtinit
  559.     mov    di,offset ledinitstr
  560.     rep movsb
  561. ;
  562.     mov    pgprtinit,offset leddirsq
  563.     add    initsiz,ledirsqsz
  564.     mov    ax,pprtype
  565.     add    al,'0'-A4
  566.     mov    ledcood,al
  567.     mov    ax,frmtype
  568.     add    al,'0'
  569.     mov    leddir,al
  570.     mov    ax,hopper
  571.     add    al,'0'-1
  572.     mov    ledhopper,al
  573.     jmp    ppriniend
  574. serialprt:
  575.     jne    ppriniend
  576.     cmp    frmtype,PORT
  577.     jne    ppriniend
  578.     mov    ax,hopper
  579.     add    al,'0'-1
  580.     mov    srlhopper,al
  581. csfin:
  582.     mov    cx,srlcsfsqsz
  583.     mov    dx,offset srlcsfsq
  584.     call    dosprint
  585.     jnz    csfin
  586. ppriniend:
  587.     mov    ah,5            ;機種情報読み取り
  588.     mov    di,offset prtfont
  589.     int    0afh
  590.     cmp    prtfont,0        ;0=16β
  591.     jne    prtiniend
  592.     mov    makeankbit,offset betaimgcnvt
  593.     mov    ankscale,0808h
  594. prtiniend:
  595.     ret
  596. ;
  597. prtinit     endp
  598. ;
  599. dosprint    proc
  600. ;
  601.     mov    cs:reprintflg,0
  602.     mov    cs:intflg,0
  603.     test    cx,cx
  604.     jz    prtend
  605.     mov    ah,40h
  606.     mov    bx,4
  607.     int    21h
  608.     jc    prterr
  609.     sub    cx,ax
  610.     add    dx,ax
  611.     jmp    short dosprint
  612. prtend:
  613.     mov    cs:intflg,0
  614.     ret
  615. prterr:
  616.     cmp    cs:reprintflg,0
  617.     jne    prtend
  618.     mov    errorno,ax
  619.     mov    dx,offset printmsg
  620.     mov    cx,prtmsgsiz
  621.     mov    ax,seg data
  622.     mov    ds,ax
  623.     jmp    abort
  624. ;
  625. dosprint    endp
  626. ;
  627. headmargin  proc
  628. ;
  629.     mov    ax,marginhead
  630.     mov    hmargin,ax
  631.     test    ax,ax
  632. marginloop:
  633.     jz    nohmargin
  634.     mov    cx,2
  635.     mov    dx,offset feedata
  636.     call    dosprint
  637.     jnz    nohmargin
  638.     dec    hmargin
  639.     jmp    marginloop
  640. nohmargin:
  641.     ret
  642. ;
  643. headmargin  endp
  644. ;
  645. feedprint   proc
  646. ;
  647.     cmp    creturns,YES
  648.     je    rtnprcs
  649.     mov    ah,5
  650.     mov    dl,0ch
  651.     int    21h
  652.     ret
  653. rtnprcs:
  654.     sub    ax,lincnt
  655.     neg    ax
  656.     add    ax,filline
  657.     mov    crcount,ax
  658.     cmp    crcount,0
  659. feedloop:
  660.     jz    feedend
  661.     mov    cx,2
  662.     mov    dx,offset feedata
  663.     call    dosprint
  664.     jnz    feedend
  665.     dec    crcount
  666.     jmp    feedloop
  667. feedend:
  668.     ret
  669. ;
  670. feedprint   endp
  671. ;
  672. code    ends
  673.     end
  674.